s1 = "123456"
s2 = "612345"

def func(s1, s2):
    a = -1
    b = len(s1)
    c = len(s2)
    if b != c:
        return False

    for i in s2:
        a += 1
        if s1[0] == i:
            break

    if s2[0:a] == s1[len(s1)-a:len(s1)] and s2[a:len(s2)] == s1[0:len(s1)-a]:
        return True


print(func(s1, s2))

# 方法2
def fun(a, b):
    if len(a) != len(b):
        return False
    else:
        bigA = a + a
        result = b in bigA
        return result


print(fun(s1, s2))
